/*
 * =============================================================================
 *
 *       Filename:  1078.c
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  08/17/2010 09:20:19 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Richard Ma (richard_ma), richard.ma.19850509@gmail.com
 *        Company:  Feng Huli Primary School
 *
 * =============================================================================
 */

#include	<stdlib.h>
#include	<stdio.h>
#include	<string.h>

/* 
 * ===  FUNCTION  ==============================================================
 *         Name:  main
 *  Description:  
 * =============================================================================
 */
int main ( int argc, char *argv[] )
{
    int a[10005], b[10005];
    int n, i;

    scanf("%d", &n);

    for (i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }
    memset(b, 0, sizeof(b));

    for (i=0; i<n; i++) {
        if (i >= 2) b[i] = b[i-2];
        if (i >= 3 && b[i] < b[i-3]) b[i] = b[i-3];
        b[i] += a[i];
    }

    b[n] = b[n-1] > b[n-2] ? b[n-1] : b[n-2];

    printf("%d\n", b[n]);

    return EXIT_SUCCESS;
}				/* ----------  end of function main  ---------- */
